package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 账单 相关枚举
 */
public class BillConstant {

    /**
     * 账单类型（0，支出，1收入）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum BillMode implements IntegerEnum<Integer> {

        EXPENDITURE(0, "支出"),//出账

        INCOME(1, "收入"),//入账
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        BillMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static BillConstant.BillMode getByCode(int code) {
            for (BillConstant.BillMode value : BillConstant.BillMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 收入的行为模式（0空，1充值，2订单退款余额回退，3服务退款余额回退）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum InnerMode implements IntegerEnum<Integer> {

        EMPTY(0, "空"),

        RECHARGE(1, "转入"),

        SALE_ROLLBACK(2, "订单退款余额回退"),

        SERVICE_ROLLBACK(3, "服务退款余额回退"),

        COMMISSION_TO_BALANCE(4, "佣金转存余额"),

        POINT_TO_BALANCE(5, "积分转存余额"),

        BALANCE_GIVE_AWAY(6, "余额转赠"),

        BALANCE_GAINS(7, "激活商品分润"),
//        PLATFORM_ADJUST(8, "平台转入"),
        PLATFORM_ADJUST(8, "转入"),

        BALANCE_TO_POINT(9, "余额转存积分"),

        CNHD_TO_BALANCE(10,"兑换消费额失败"),

        CNHD_BALANCE(11,"兑换消费额"),

        POINT_WITHDRAWAL(12, "积分提现"),

        POINT_CONVERSION(13, "积分转赠"),

        MONTHLY_DIVIDENDS(14, "月度分红"),

        ORDER_DIVIDENDS(15, "会员下单分红"),

        WRITE_OFF(16, "订单核销"),

        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        InnerMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static BillConstant.InnerMode getByCode(int code) {
            for (BillConstant.InnerMode value : BillConstant.InnerMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public static String getMsgByCode(int code) {
            InnerMode[] innerModes = values();
            for (InnerMode innerMode : innerModes) {
                if (innerMode.getCode().equals(code)) {
                    return innerMode.getMsg();
                }
            }
            return null;
        }
    }

    /**
     * 支出的行为模式（0空，1消费）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OuterMode implements IntegerEnum<Integer> {

        EMPTY(0, "空"),

        CONSUME(1, "消费"),

        BALANCE_GIVE_AWAY(2, "余额转赠"),
//        PLATFORM_ADJUST(3, "平台转入"),
        PLATFORM_ADJUST(3, "转入"),
//        BALANCE_TO_POINT(4, "平台转入"),
        BALANCE_TO_POINT(4, "转入"),
        EXCHANGE_FOR_CNHD(5, "兑换消费额"),
        EXCHANGE_CNHD(6, "兑换消费额"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OuterMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static BillConstant.OuterMode getByCode(int code) {
            for (BillConstant.OuterMode value : BillConstant.OuterMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public static String getMsgByCode(int code) {
            OuterMode[] outerModes = values();
            for (OuterMode outerMode : outerModes) {
                if (outerMode.getCode().equals(code)) {
                    return outerMode.getMsg();
                }
            }
            return null;
        }
    }


    /**
     * 0余额充值，
     * 1购买商品或服务,
     * 2退款，
     * 3商家所得提现，
     * 4会员分佣金提现
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum BillType implements IntegerEnum<Integer> {

        BALANCE_RECHARGE(0, "余额转入"),

        BUY_GOODS(1, "购买商品或服务"),

        REFUND(2, "退款"),

        SHOP_WITHDRAW(3, "商家所得提现"),

        MEMBER_WITHDRAW(4, "会员分佣金提现"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        BillType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static BillConstant.BillType getByCode(int code) {
            for (BillConstant.BillType value : BillConstant.BillType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


}
